<!DOCTYPE html>
<html ng-app="App">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>老师信息</title>
    <script src="js/jquery-3.2.1.min.js" type="text/javascript"></script>
    <script src="js/bootstrap.min.js" type="text/javascript"></script>
    <script src="js/angular.js" type="text/javascript"></script>
    <script src="js/laydate/laydate.js" type="text/javascript"></script>
    <script src="js/bootstrapValidator.min.js" type="text/javascript"></script>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <style type="text/css">
        a,
        .pagination>li>a {
            color: #1abc9c;
        }
        
        .col-md-4 {
            padding-right: 0px;
        }
        
        .help-block {
            display: inline-block;
            margin: 0px;
        }
        
        .pagination>li>a {
            width: 42px;
            text-align: center;
        }
        
        .pagination>li>.pageon {
            background-color: #ddd;
        }
        
        .nomargintop {
            margin: 0px auto;
        }
        
        tr {
            text-align: center;
        }
        
        th {
            text-align: center;
        }
    </style>
</head>

<body ng-controller="Aaa">
    <div class="container-fluid" style="padding:20px 30px;">
        <!-- 主界面 -->
        <div class="row" style="margin-top:20px;margin-bottom:20px;" ng-show='mainshow'>
            <!-- 头部 -->
            <div class="col-md-1">
                <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;">教师姓名 :</p>
            </div>
            <div class="col-md-4">
                <input type="text" class="form-control" id="teacherNname" ng-model="teacherNname" placeholder="教师姓名">
            </div>
            <div class="col-md-5">
                <button type="button" class="btn btn-primary" ng-click="search()" style="margin:0px 20px;">搜索</button>

                <button type="button" class="btn btn-primary" ng-click="excelImport()" style="margin:0px 20px;">Excel导入</button>

                <button type="button" class="btn btn-primary" ng-click="add()" style="margin:0px 20px;">新增</button>
            </div>
        </div>
        <!-- 数据展示 -->
        <div class="row" ng-show='mainshow'>
            <div class="col-md-12">
                <table class="table table-hover table-bordered">
                    <thead>
                        <tr>
                            <th width="5%">编号</th>
                            <th width="20%">姓名</th>
                            <th width="5%">性别</th>
                            <th width="20%">手机号</th>
                            <th width="30%">科目</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="item in teacherInfo track by $index">
                            <td>{{$index+1}}</td>
                            <td>{{item.Title}}</td>
                            <td ng-bind="item.Sex=='1'?'男':'女'"></td>
                            <td>{{item.Phone}}</td>
                            <td>
                                <span ng-repeat="subject in item.SubjectId track by $index" ng-bind="subjectsArr[subject]+',&nbsp;'"></span>
                            </td>
                            <td>
                                <a href="javascript:;" ng-click="detail(item)">详细信息</a>&nbsp; &nbsp;|&nbsp;&nbsp;
                                <a href="javascript:;" ng-click="update(item)">修改</a>&nbsp; &nbsp;|&nbsp;&nbsp;
                                <a href="javascript:;" ng-click="delete(item)" data-toggle="modal" data-target="#myModal">删除</a>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <!-- Modal -->
            <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title" id="myModalLabel">删除</h4>
                        </div>
                        <div class="modal-body">确认删除"{{deleterealname}}"这名教师的信息？</div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">否</button>
                            <button type="button" class="btn btn-primary" ng-click="deletereal()" data-dismiss="modal">是</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- 分页 -->
        <div class="row" ng-show='mainshow'>
            <div class="col-md-12" style="text-align: center;">
                <nav aria-label="Page navigation">
                    <ul class="pagination nomargintop">
                        <li>
                            <a href="javascript:;" aria-label="Previous" ng-click="Previous()">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                        <li ng-repeat="page in pageArr track by $index">
                            <a ng-if="page==pageon" class="pageon" href=" javascript:;" ng-click="changepage(page)">{{page}}</a>
                            <a ng-if="page!=pageon" href=" javascript:;" ng-click="changepage(page)">{{page}}</a>
                        </li>
                        <li>
                            <a href="javascript:;" aria-label="Next" ng-click="Next()">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </ul>
                </nav>
                <div style="text-align:center;">当前共{{pages}}页</div>
            </div>
        </div>
        <!-- 角色详情页 -->
        <div class="row" ng-show='detailshow' style="margin-top:20px;margin-bottom:20px;">

            <div class="col-md-8">
                <table class="table table-hover table-bordered">
                    <tbody>
                        <tr>
                            <th width="16%">姓名</th>
                            <td>{{oneData.Title}}</td>
                        </tr>
                        <tr>
                            <th width="16%">性别</th>
                            <td ng-bind="oneData.Sex=='1' ? '男': '女'"></td>
                        </tr>
                        <tr>
                            <th width="16%">出生年月</th>
                            <td ng-bind="oneData.Birthday"></td>
                        </tr>
                        <tr>
                            <th width="16%">籍贯</th>
                            <td ng-bind="oneData.Origin"></td>
                        </tr>
                        <tr>
                            <th width="16%">党派</th>
                            <td ng-bind="oneData.Clan"></td>
                        </tr>
                        <tr>
                            <th width="16%">民族</th>
                            <td ng-bind="oneData.Nation"></td>
                        </tr>
                        <tr>
                            <th width="16%">学历</th>
                            <td ng-bind="oneData.Edu"></td>
                        </tr>
                        <tr>
                            <th width="16%">职称</th>
                            <td ng-bind="oneData.PfTitle"></td>
                        </tr>
                        <tr>
                            <th width="16%">职务</th>
                            <td ng-bind="oneData.Post"></td>
                        </tr>
                        <tr>
                            <th width="16%">手机号</th>
                            <td>{{oneData.Phone}}</td>
                        </tr>
                        <tr>
                            <th width="16%">科目</th>
                            <td>
                                <span ng-repeat="subject in oneData.SubjectId track by $index" ng-bind="subjectsArr[subject]+ ',&nbsp;'"></span>
                            </td>
                        </tr>
                        <tr>
                            <th width="16%">身份证号</th>
                            <td>{{oneData.Card}}</td>
                        </tr>
                        <!--                         <tr>
                            <th width="16%">在职类型</th>
                            <td ng-if ="oneData.type=='1'">离职</td>
                            <td ng-if ="oneData.type=='2'">在职</td>
                            <td ng-if ="oneData.type=='3'">退休</td>
                        </tr>
                        <tr>
                            <th width="16%">在职状态</th>
                            <td ng-if="oneData.job_status=='1'">全职</td>
                            <td ng-if="oneData.job_status=='2'">兼职</td>
                            <td ng-if="oneData.job_status=='3'">实习</td>
                        </tr> -->
                        <tr>
                            <th width="16%">Email</th>
                            <td>{{oneData.Email}}</td>
                        </tr>
                        <tr>
                            <th width="16%">QQ</th>
                            <td>{{oneData.QQ}}</td>
                        </tr>
                        <!--          <tr>
                            <th width="16%">微信</th>
                            <td>{{oneData.wechat}}</td>
                        </tr> -->
                        <tr>
                            <th width="16%">入职日期</th>
                            <td>{{oneData.TeachTime}}</td>
                        </tr>
                        <!--                         <tr>
                            <th width="16%">转正日期</th>
                            <td>{{oneData.become_regular_time}}</td>
                        </tr> -->
                        <!--  <tr>
                            <th width="16%">备注</th>
                            <td>{{oneData.remark}}</td>
                        </tr> -->
                    </tbody>
                </table>
                <div class="row">
                    <div class="col-md-6 col-md-offset-2">
                        <button type="button" class="btn btn-primary" ng-click="update(oneData)">修改</button>
                        <button type="button" class="btn btn-default active" ng-click="backmain()">返回</button>
                    </div>

                </div>
            </div>
        </div>
        <!-- 修改或添加 -->
        <div class="row" ng-show='updateshow' style="margin-top:20px;margin-bottom:20px;">
            <form name="myForm" id="defaultForm" novalidate>
                <div class="col-md-12">
                    <div class="row" style="margin-bottom: 15px;">
                        <div class="col-md-1">
                            <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;">姓名 :</p>
                        </div>
                        <div class="col-md-4 form-group">
                            <input type="text" name="Title" class="form-control" placeholder="请输入姓名" ng-model="oneData.Title">
                        </div>
                    </div>
                    <div class="row" style="margin-bottom: 15px;">
                        <div class="col-md-1">
                            <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;">性别 :</p>
                        </div>
                        <div class="col-md-4" style="height:34px;line-height: 34px;">
                            <label>
                                <input name="sex" type="radio" value="1" ng-checked="oneData.Sex=='1'" style="position: relative;">&nbsp;男&nbsp;&nbsp;&nbsp;
                            </label>
                            <label>
                                <input name="sex" type="radio" value="2" ng-checked="oneData.Sex=='2'" style="position: relative;">&nbsp;女
                            </label>
                        </div>
                    </div>
                    <div class="row" style="margin-bottom: 15px;">
                        <div class="col-md-1">
                            <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;">出生年月 :</p>
                        </div>
                        <div class="col-md-4 form-group">
                            <input type="text" id="Birthday" name="Birthday" class="laydate-icon form-control" style="height:34px;" ng-blur="Birthday()" onclick="laydate()" placeholder="请选择出生年月" ng-model="oneData.Birthday">
                        </div>
                    </div>
                    <div class="row" style="margin-bottom: 15px;">
                        <div class="col-md-1">
                            <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;">籍贯 :</p>
                        </div>
                        <div class="col-md-4 form-group">
                            <input type="text" name="Origin" class="form-control" placeholder="请填写籍贯" ng-model="oneData.Origin">
                        </div>
                    </div>
                    <div class="row" style="margin-bottom: 15px;">
                        <div class="col-md-1">
                            <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;">党派 :</p>
                        </div>
                        <div class="col-md-4 form-group">
                            <input type="text" name="Clan" class="form-control" placeholder="请填写党派" ng-model="oneData.Clan">
                        </div>
                    </div>
                    <div class="row" style="margin-bottom: 15px;">
                        <div class="col-md-1">
                            <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;">民族 :</p>
                        </div>
                        <div class="col-md-4 form-group">
                            <input type="text" name="Nation" class="form-control" placeholder="请填写民族" ng-model="oneData.Nation">
                        </div>
                    </div>
                    <div class="row" style="margin-bottom: 15px;">
                        <div class="col-md-1">
                            <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;">学历 :</p>
                        </div>
                        <div class="col-md-4 form-group">
                            <input type="text" name="Edu" class="form-control" placeholder="请填写学历" ng-model="oneData.Edu">
                        </div>
                    </div>
                    <div class="row" style="margin-bottom: 15px;">
                        <div class="col-md-1">
                            <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;">职称 :</p>
                        </div>
                        <div class="col-md-4 form-group">
                            <input type="text" name="PfTitle" class="form-control" placeholder="请填写职称" ng-model="oneData.PfTitle">
                        </div>
                    </div>
                    <div class="row" style="margin-bottom: 15px;">
                        <div class="col-md-1">
                            <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;">职务 :</p>
                        </div>
                        <div class="col-md-4 form-group">
                            <input type="text" name="Post" class="form-control" placeholder="请填写职务" ng-model="oneData.Post">
                        </div>
                    </div>
                    <div class="row" style="margin-bottom: 15px;">
                        <div class="col-md-1">
                            <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;">手机号 :</p>
                        </div>
                        <div class="col-md-4 form-group" style="height:34px;line-height: 34px;">
                            <input type="text" name="Phone" class="form-control" placeholder="请输入手机号" ng-model="oneData.Phone">
                        </div>
                    </div>
                    <div class="row" style="margin-bottom: 15px;">
                        <div class="col-md-1">
                            <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;">身份证号 :</p>
                        </div>
                        <div class="col-md-4 form-group" style="height:34px;line-height: 34px;">
                            <input type="text" name="Card" class="form-control" placeholder="请输入身份证号" ng-model="oneData.Card">
                        </div>
                    </div>
                    <!--                 <div class="row" style="margin-bottom: 15px;">
                        <div class="col-md-1">
                            <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;">在职状态 :</p>
                        </div>
                        <div class="col-md-4" style="height:34px;line-height: 34px;">
                            <select class="form-control" ng-model ="oneData.job_status">
                                <option value="" style="display: none;"></option>
                                <option value="1">离职</option>
                                <option value="2">在职</option>
                                <option value="3">退休</option>
                            </select>
                        </div>
                    </div>
                    <div class="row" style="margin-bottom: 15px;">
                        <div class="col-md-1">
                            <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;">在职类型 :</p>
                        </div>
                        <div class="col-md-4" style="height:34px;line-height: 34px;">
                            <select class="form-control"  ng-model ="oneData.type">
                                <option value="" style="display: none;"></option>
                                <option value="1">全职</option>
                                <option value="2">兼职</option>
                                <option value="3">实习</option>
                            </select>
                        </div>
                    </div> -->
                    <div class="row" style="margin-bottom: 15px;">
                        <div class="col-md-1">
                            <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;">科目 :</p>
                        </div>
                        <div class="col-md-4" style="height:34px;line-height: 34px;">
                            <label ng-repeat="op in subjects track by $index">
                                <input name="SubjectId" type="checkbox" value="{{op.Id}}" ng-checked="oneData.SubjectId.indexOf(op.Id)>-1" style="position: relative;">&nbsp;{{op.Title}}&nbsp;&nbsp;&nbsp;
                            </label>
                        </div>
                    </div>
                    <div class="row" style="margin-bottom: 15px;">
                        <div class="col-md-1">
                            <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;">Email :</p>
                        </div>
                        <div class="col-md-4 form-group" style="height:34px;line-height: 34px;">
                            <input type="text" name="Email" class="form-control" placeholder="请输入Email" ng-model="oneData.Email">
                        </div>
                    </div>
                    <div class="row" style="margin-bottom: 15px;">
                        <div class="col-md-1">
                            <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;">QQ :</p>
                        </div>
                        <div class="col-md-4 form-group" style="height:34px;line-height: 34px;">
                            <input type="text" name="QQ" class="form-control" placeholder="请输入QQ" ng-model="oneData.QQ">
                        </div>
                    </div>
                    <!--                 <div class="row" style="margin-bottom: 15px;">
                        <div class="col-md-1">
                            <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;">微信 :</p>
                        </div>
                        <div class="col-md-4" style="height:34px;line-height: 34px;">
                            <input type="text" class="form-control" placeholder="请输入微信"  ng-model ="oneData.wechat" >
                        </div>
                    </div> -->
                    <div class="row" style="margin-bottom: 15px;">
                        <div class="col-md-1">
                            <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;">入职日期 :</p>
                        </div>
                        <div class="col-md-4 form-group" style="height:34px;line-height: 34px;">
                            <input id="dateIn" name="TeachTime" placeholder="请输入入职日期" class="laydate-icon form-control" style="height:34px;" onclick="laydate()" ng-model="oneData.TeachTime">
                        </div>
                    </div>
                    <!--                 <div class="row" style="margin-bottom: 15px;">
                        <div class="col-md-1">
                            <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;">转正日期 :</p>
                        </div>
                        <div class="col-md-4" style="height:34px;line-height: 34px;">
                            <input id="dateReal"  placeholder="请输入转正日期" class="laydate-icon form-control" style="height:34px;" onclick="laydate()" ng-model ="oneData.become_regular_time" >
                        </div>
                    </div> -->
                    <div class="row" style="margin-bottom: 15px;">
                        <div class="col-md-1">
                            <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;">联系地址 :</p>
                        </div>
                        <div class="col-md-4 form-group">
                            <textarea class="form-control" name="Address" placeholder="请输入联系地址" ng-model="oneData.Address">xx路xx街道xx小区</textarea>
                        </div>
                    </div>
                    <!--   <div class="row" style="margin-bottom: 15px;">
                        <div class="col-md-1">
                            <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;">备注 :</p>
                        </div>
                        <div class="col-md-4">
                            <textarea placeholder="请输入备注" ng-model ="oneData.remark"  class="form-control"></textarea>
                        </div>
                    </div> -->

                    <div class="form-group">
                        <div class="col-md-1">
                            <p style="font-weight: bold;width:100%;height:34px;text-align: right;line-height: 34px;margin:0px;"> </p>
                        </div>
                        <button class="btn btn-primary ajax-post" ng-click="save()">保存</button>
                        <button class="btn btn-default active" ng-click="backmain()">返回</button>
                    </div>
                </div>
            </form>
        </div>

        <div class="modal fade" id="ModalOK" tabindex="-1" role="dialog" aria-labelledby="myModalLabel1">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel1">提示</h4>
                    </div>
                    <div class="modal-body">
                        提交成功
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-primary" data-dismiss="modal">确定</button>
                    </div>
                </div>
            </div>
        </div>

    </div>
    <script src="js/angular.common.js" type="text/javascript"></script>
    <script type="text/javascript">
        app.controller('Aaa', ['$scope', '$http', "$timeout", "common", function($scope, $http, $timeout, common) {

            $scope.url = "http://localhost/tp5-school/public/";
            $scope.reset = function() {
                $scope.teacherInfo = []; //所有老师信息
                $scope.oneData = {}; //一条数据
                $scope.mainshow = true; //默认显示主体

                $scope.teacherNname = ""; //搜索框老师名称

                $scope.subjects = []; //所有在教授的科目

                $scope.subjectsArr = []; //科目中文

                //分页
                $scope.pages = 0;
                $scope.pageArr = [];
                $scope.pageon = 0; //当前的页数

                //获取所有的教学科目
                $http({
                    method: "get",
                    url: $scope.url + "subject"
                }).then(function(data) {
                    $scope.subjects = data.data.data;
                    $scope.subjects.forEach(function(item) {
                        $scope.subjectsArr[parseInt(item.Id)] = item.Title;
                    });

                })

                $http({
                    method: "get",
                    url: $scope.url + "teacher"
                }).then(function(data) {

                    $scope.teacherInfo = [];
                    $scope.teacherInfo = data.data.data;
                    $scope.pages = data.data.pages;

                    for (var i = 0; i < $scope.teacherInfo.length; i++) {
                        if ($scope.teacherInfo[i].SubjectId) {
                            $scope.teacherInfo[i].SubjectId = JSON.parse($scope.teacherInfo[i].SubjectId);
                        } else {
                            $scope.teacherInfo[i].SubjectId = [];
                        }
                    }

                    $scope.pageon = 1;
                    $scope.pageArr = common.pageshow($scope.pageon, $scope.pages);
                })

            }
            $scope.reset();


            //改变页数
            $scope.changepage = function(page) {
                $scope.pageon = page;
            }

            //上一页Previous
            $scope.Previous = function() {
                if ($scope.pageon > 1) {
                    $scope.pageon--;
                }
            }

            //下一页Next
            $scope.Next = function() {
                if ($scope.pageon < $scope.pages) {
                    $scope.pageon++;
                }
            }



            //监听当前页的变化
            $scope.$watch('pageon', function(newValue, oldValue, scope) {
                if ($scope.pageon == 0) {
                    return false;
                };
                //获取所有老师信息
                $http({
                    method: "get",
                    url: $scope.url + "teacher?title=" + $scope.teacherNname + "&page=" + $scope.pageon
                }).then(function(data) {

                    $scope.teacherInfo = [];
                    $scope.teacherInfo = data.data.data;
                    $scope.pages = data.data.pages;

                    for (var i = 0; i < $scope.teacherInfo.length; i++) {
                        if ($scope.teacherInfo[i].SubjectId) {
                            $scope.teacherInfo[i].SubjectId = JSON.parse($scope.teacherInfo[i].SubjectId);
                        } else {
                            $scope.teacherInfo[i].SubjectId = [];
                        }
                    }
                    $scope.pageArr = common.pageshow($scope.pageon, $scope.pages);
                })

            })






            $scope.detailshow = false;
            $scope.updateshow = false;
            //添加
            $scope.add = function() {
                $scope.mainshow = false; //默认显示主体
                $scope.updateshow = true;
                $scope.oneData = {};

            }

            //保存
            $scope.save = function() {
                var subject_arr = [];

                $scope.oneData.TeachTime = $("#dateIn").val();
                $scope.oneData.Birthday = $("#Birthday").val();

                $scope.oneData.sex = $("input[type='radio'][name='sex']:checked").val();

                for (var i = 0; i < $("input[type='checkbox'][name='SubjectId']:checked").length; i++) {
                    subject_arr.push(parseInt($("input[type='checkbox'][name='SubjectId']:checked")[i].value));
                }
                $scope.oneData.SubjectId = JSON.stringify(subject_arr);
                console.log($scope.oneData);
                var url = $scope.url + "teacher";
                var method = "post";
                if ($scope.oneData.Id) {
                    url = $scope.url + "teacher/" + $scope.oneData.Id;
                    method = "put";
                }

                $http({
                    method: method,
                    url: url,
                    data: $scope.oneData
                }).then(function(data) {
                    $('#ModalOK').modal('show');
                    $timeout(function() {
                        $('#ModalOK').modal('hide');
                        $scope.backmain();
                    }, 1500);
					$scope.reset();
                });

                // $.ajax({
                //     method: method,
                //     url: url,
                //     data: $scope.oneData,
                //     dataType: "json",
                //     success: function(data) {
                //         $('#ModalOK').modal('show');
                //         $timeout(function() {
                //             $('#ModalOK').modal('hide');
                //             $scope.backmain();
                //         }, 1500);

                //     }
                // })
            }

            //显示详情
            $scope.detail = function(item) {
                $scope.oneData = item;
                $scope.mainshow = false; //默认显示主体
                $scope.detailshow = true;
                $scope.updateshow = false;
            }

            //修改
            $scope.update = function(item) {
                $scope.oneData = item
                $scope.mainshow = false; //默认显示主体
                $scope.detailshow = false;
                $scope.updateshow = true;



            }

            $scope.delitem = {}; //删除的数据
            $scope.deleterealname = ""; //确认删除的老师的名字

            //点击删除
            $scope.delete = function(item) {
                $scope.delitem = item;
                $scope.deleterealname = item.Title;
            }

            //点击“是”确认删除
            $scope.deletereal = function() {
                $http({
                    method: "delete",
                    url: $scope.url + "teacher/" + $scope.delitem.Id,
                }).then(function(data) {

                    $('#ModalOK').modal('show');
                    $timeout(function() {
                        $('#ModalOK').modal('hide');
                    }, 1500);
                    $scope.reset();

                })

                // $.ajax({
                //     method: "delete",
                //     url: $scope.url + "teacher/" + $scope.delitem.Id,
                //     success: function(data) {
                //         $('#ModalOK').modal('show');
                //         $timeout(function() {
                //             $('#ModalOK').modal('hide');
                //             $scope.backmain();
                //         }, 1500);

                //     }
                // })
            }

            //所有的返回主界面
            $scope.backmain = function() {
                $scope.mainshow = true; //默认显示主体
                $scope.oneData = {}; //一条数据
                $scope.detailshow = false;
                $scope.updateshow = false;
            }

            //查询
            $scope.search = function() {

                $scope.pageon = 0;
                $scope.pages = 0;
                $scope.pageArr = [];
                $scope.teacherInfo = [];
                $http({
                    method: "get",
                    url: $scope.url + "teacher?title=" + $scope.teacherNname
                }).then(function(data) {
                    $scope.pages = data.data.pages;
                    $scope.pageon = 1;
                    for (var i = 0; i < 7; i++) {
                        if (i < $scope.pages) {
                            $scope.pageArr.push(i + 1);
                        }
                    }
                    $scope.teacherInfo = data.data.data;
                    for (var i = 0; i < $scope.teacherInfo.length; i++) {
                        $scope.teacherInfo[i].SubjectId = JSON.parse($scope.teacherInfo[i].SubjectId);

                    }
                })
            }

            //excel导入
            $scope.excelImport = function() {
                alert('导入文件！');

            }



        }]);


        $('#defaultForm').bootstrapValidator({
            excluded: [":disabled"],
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            live: 'enabled',
            fields: { /*验证：规则*/
                Title: { //验证input项：验证规则
                    message: '姓名无效,',

                    validators: {
                        notEmpty: { //非空验证：提示消息
                            message: '用户名不能为空,'
                        },
                        stringLength: {
                            min: 1,
                            max: 10,
                            message: '用户名长度必须在1到10之间,'
                        }
                    }
                },
                Email: {
                    validators: {
                        notEmpty: {
                            message: '邮件不能为空,'
                        },
                        regexp: {
                            regexp: /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/,
                            message: '请输入正确的邮件地址如：65974040@qq.com,'
                        }
                    }
                },
                Birthday: {
                    validators: {
                        notEmpty: {
                            message: '生日不能为空,'
                        }
                    }
                },
                TeachTime: {
                    validators: {
                        notEmpty: {
                            message: '入职时间不能为空,'
                        }
                    }
                },
                Phone: {
                    message: '手机号码无效,',
                    validators: {
                        notEmpty: {
                            message: '手机号码不能为空,'
                        },
                        stringLength: {
                            min: 11,
                            max: 11,
                            message: '请输入11位手机号码,'
                        },
                        regexp: {
                            regexp: /^1[3|5|8]{1}[0-9]{9}$/,
                            message: '请输入正确的手机号码,'
                        }
                    }
                },
                Origin: {
                    validators: {
                        notEmpty: {
                            message: '籍贯不能为空'
                        }
                    }
                },
                Clan: {
                    validators: {
                        notEmpty: {
                            message: '党派不能为空'
                        }
                    }
                },
                Nation: {
                    validators: {
                        notEmpty: {
                            message: '名族不能为空'
                        }
                    }
                },
                Edu: {
                    validators: {
                        notEmpty: {
                            message: '学历不能为空'
                        }
                    }
                },
                PfTitle: {
                    validators: {
                        notEmpty: {
                            message: '职称不能为空'
                        }
                    }
                },
                Post: {
                    validators: {
                        notEmpty: {
                            message: '职务不能为空'
                        }
                    }
                },
                Card: {
                    validators: {
                        notEmpty: {
                            message: '身份证不能为空'
                        },
                        regexp: {
                            regexp: /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
                            message: '请输入正确的身份证,'
                        }
                    }
                },
                QQ: {
                    validators: {
                        notEmpty: {
                            message: 'QQ不能为空'
                        },
                        regexp: {
                            regexp: /^[1-9][0-9]{4,10}$/,
                            message: '请输入正确的QQ,'
                        }
                    }
                },
                Address: {
                    validators: {
                        notEmpty: {
                            message: '住址不能为空'
                        }
                    }
                }
            }
        }).on('success.form.bv', function(e) {
            console.log(1111111111111);
        });
    </script>
</body>

</html>